package com.tm.servicemsm.controller;

import com.tm.servicemsm.demos.SalesRanking;
import com.tm.servicemsm.demos.SalesService;
import com.tm.servicemsm.demos.StatisticalTable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 2024/7/19 实现管理端首页的统计报表，和售卖机销售排行榜功能 Cjj
 */
@RestController
@RequestMapping("/AdminDashboard")
public class AdminDashboardController {
    private SalesService salesService;
 
  /*  public AdminDashboardController(SalesService salesService) {
        this.salesService = salesService;
    }
 
    public Map<String, StatisticalTable> fetchDashboardData() {
        Map<String, Integer> statisticalData = salesService.getStatisticalData();
        List<SalesRanking> salesRanking = salesService.getSalesRanking();
        // 将排行榜数据添加到统计报表中
        // 假设我们要添加的是排行前五的售卖机
        int rank = 1;
        for (int i = 0; i < Math.min(5, salesRanking.size()); i++) {
            SalesRanking ranking = salesRanking.get(i);
            dashboardData.put("Rank " + rank++, new StatisticalTable(ranking.getMachineModel(), ranking.getSalesCount()));
        }
        return dashboardData;*/
    }